package diamondRingService.impl;

import diamondRingDao.impl.OrderDaoImpl;
import diamondRingEntity.Collection;
import diamondRingEntity.Order;
import diamondRingEntity.OrderGoods;
import diamondRingService.OrderService;

import java.util.List;

public class OrderServiceImpl implements OrderService {
    OrderDaoImpl orderDao=new OrderDaoImpl();
    @Override
    public int orderInsert(Order order) {
        int count=0;
        if (order!=null){
            count=orderDao.orderInsert(order);
        }else {
            count=-1;
        }
        return count;
    }

    @Override
    public int orderGoodsInsert(OrderGoods orderGoods) {
        int count=0;
        if (orderGoods!=null){
            count=orderDao.orderGoodsInsert(orderGoods);
        }else {
            count=-1;
        }
        return count;
    }

    @Override
    public int orderFindId(String orderNumber) {
        int count=0;
        if (orderNumber!=null){
            count=orderDao.orderFindId(orderNumber);
        }else {
            count=-1;
        }
        return count;
    }

    @Override
    public int orderState(int goodsId, int userid) {
        int count=0;
        if (goodsId>0&&userid>0){
            count=orderDao.orderState(goodsId,userid);
        }else {
            count=-1;
        }
        return count;
    }

    @Override
    public List<Order> orderFind(int userid) {
       List<Order> orders=null;
         if (userid>0){
            orders=orderDao.orderFind(userid);
        }
        return orders;
    }

    @Override
    public List<Order> orderInformation(String orderNumber) {
        List<Order> orders=null;
        if (orderNumber!=null){
            orders=orderDao.orderInformation(orderNumber);
        }
        return orders;
    }

    @Override
    public int orderCancel(int id) {
        int count=0;
        if (id>0){
            count=orderDao.orderCancel(id);
        }else {
            count=-1;
        }
        return count;
    }


}
